// web/src/app/(employee)/search/page.tsx
import React from 'react';
import SearchInput from "@/app/(employee)/search/_components/search-input";
import {db} from "@/lib/db";
import SearchEmployeeList from "@/app/(employee)/search/_components/search-employee-list";

const Page = async ({searchParams}: {
    searchParams: {
        value: string
    }
}) => {
    const employees = await db.employee.findMany({
        where: {
            'OR': [
                {
                    name: {
                        contains: searchParams.value
                    },
                },
                {
                    description: {
                        contains: searchParams.value
                    }
                }
            ]
        },
        include: {
            company: true,
            education: true,
            hr: true
        }
    })

    return (
        <>
            <div className={`px-6 pt-6 md:hidden md:mb-0 block`}>
                <SearchInput/>
            </div>
            <div className={`p-6 space-y-4`}>
                {/*@ts-ignore*/}
                <SearchEmployeeList employees={employees}/>
            </div>
        </>
    );
};

export default Page;